package com.hqyj.javaGraduation.hotel.controller;

import com.hqyj.javaGraduation.hotel.pojo.HotelMenu;
import com.hqyj.javaGraduation.hotel.pojo.HotelPackage;
import com.hqyj.javaGraduation.hotel.service.HotelMenuService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/menu")
public class HotelMenuController {
    @Autowired
    HotelMenuService hotelMenuService;

    /**
     * 新增菜品
     * 127.0.0.1:8080/menu/addMenu    ---   get
     * {"menuName":"麻婆豆腐","menuCost":15,"menuPrice":20,"menuClass":"熟食","menuDepartment":3}
     */
    @GetMapping("/addMenu")
    public HashMap<String, Object> addMenu(HotelMenu hotelMenu) {
        return hotelMenuService.addMenu(hotelMenu);
    }

    /**
     * 修改菜品
     * 127.0.0.1:8080/menu/updateMenu    ---   get
     * {"menuId":"1","menuName":"鱼香茄子","menuCost":10,"menuPrice":25,"menuClass":"熟食","menuDepartment":3}
     */
    @GetMapping("/updateMenu")
    public HashMap<String, Object> updateMenu( HotelMenu hotelMenu) {
        return hotelMenuService.updateMenu(hotelMenu);
    }

    /**
     * 删除菜品
     * 127.0.0.1:8080/menu/delMenuById?id=3    ---   get
     */
    @GetMapping(value = "/delMenuById")
    public HashMap<String, Object> delMenuById(Integer id) {
        return hotelMenuService.delMenuById(id);
    }

    /**
     * 分页查询菜单列表
     *
     * 127.0.0.1:8080/menu/menuList    ---   get
     * {"page":"1","row":"2"}
     */
    @GetMapping("/menuList")
    public HashMap<String, Object> menuList(HotelMenu hotelMenu) {
        return hotelMenuService.menuList(hotelMenu);
    }

    /**
     * 新增菜品到套餐
     *
     * 127.0.0.1:8080/menu/addMenuToPkg/2/2    ---   get
     * {"hotelMenu":"{'menuId':2}","hotelPackage":"{'pacId':3}"}
     */
    @GetMapping(value = "/addMenuToPkg/{menuId}/{pacId}")
    public HashMap<String, Object> addMenuToPkg(@PathVariable Integer menuId, @PathVariable Integer pacId) {
        return hotelMenuService.addMenuToPkg(menuId, pacId);
    }

    /**
     * 套餐中删除菜品
     *
     * 127.0.0.1:8080/menu/delMenuPkg/2/2    ---  delete
     * {"hotelMenu":"{'menuId':2}","hotelPackage":"{'pacId':3}"}
     */
    @DeleteMapping(value = "/delMenuPkg/{menuId}/{pacId}")
    public HashMap<String, Object> delMenuPkg(@PathVariable Integer menuId, @PathVariable Integer pacId) {
        return hotelMenuService.delMenuPkg(menuId, pacId);
    }

    /**
     * 套餐中查询套餐
     *
     * 127.0.0.1:8080/menu/getMenuPkg    ---  get
     * {"hotelMenu":"{'menuId':2}","hotelPackage":"{'pacId':3}"}
     */
    @GetMapping(value = "/getMenuPkg")
    public HashMap<String, Object> getMenuPkg() {
        return hotelMenuService.getMenuPkg();

    }
}
